package com.demo.app.testvolley;

import android.content.Context;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

/**
 * 类描述
 *
 * @author <a href="mailto:903714484@qq.com">zhuting</a> on  2020/3/16$ 13:26$
 * @version 1.0
 * Copyright © 2019, www.yetancaijing.com All Rights Reserved.
 * 上海檀香文化咨询有限公司版权所有.
 */
public class VolleySingleton {

    private static VolleySingleton instance;
    private RequestQueue requestQueue;
    private Context context;

    private VolleySingleton(Context context) {
        this.context = context;
        requestQueue = getRequestQueue();
    }

    public static synchronized VolleySingleton getInstance(Context con) {
        if(instance == null){
            instance = new VolleySingleton(con);
        }
        return instance;
    }

    public RequestQueue getRequestQueue() {
        if(requestQueue == null){
            requestQueue = Volley.newRequestQueue(context.getApplicationContext());
        }
        return requestQueue;
    }
}
